package utils.version6;


import java.lang.reflect.Proxy;

public class TxProxyFactory {
    //private boolean enableTransaction = false;//模拟时候添加了事务切面,但不需要设置了，通过解析注解 来识别是否需要开启事务

    private TransactionManager transactionManager;

    public void setTransactionManager(TransactionManager transactionManager) {
        this.transactionManager = transactionManager;
    }


    public Object getBean(Object target) {

        return Proxy.newProxyInstance(target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),
                new TxInvocationHandler(target, transactionManager));


    }
}

